<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var findNumberIn2DArray = function(matrix, target) {
    let i = 0
    if(matrix.join() === ''){
        return false
    }
    while(i<matrix.length){
        if(matrix[i][matrix[i].length-1]<target){
            i++
        }else if(matrix[i][matrix[i].length-1]>target){
            for(let j = 0;j<matrix[0].length;j++){
                if(target === matrix[i][j]){
                    return true
                }
                if(j === matrix[i].length-1){
                  i++
                }
            }
        } else {
            return true
        }
    }
    return false
};
// console.log(findNumberIn2DArray([[]],20));
// console.log(findNumberIn2DArray([],20));
console.log(findNumberIn2DArray([[1,1]],0))
console.log(findNumberIn2DArray([[-5]],-5))

  </script>
</body>
</html>